package ge.telasi.tasks.ejb;

import ge.telasi.tasks.model.AppConfig;
import ge.telasi.tasks.model.TaskAttachment;
import ge.telasi.tasks.model.FlowPermission;
import ge.telasi.tasks.model.Group;
import ge.telasi.tasks.model.Structure;
import ge.telasi.tasks.model.Task;
import ge.telasi.tasks.model.TaskList;
import ge.telasi.tasks.model.TaskReceiver;
import ge.telasi.tasks.model.TaskRelation;
import ge.telasi.tasks.model.User;
import ge.telasi.tasks.search.Condition;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import javax.ejb.Remote;

/**
 * @author dimitri
 */
@Remote
public interface TaskFacadeRemote {

    // -- Structure

    List<Structure> getRootStructures();
    Structure createStructure(Map credentials, Structure structure);
    Structure updateStructure(Map credentials, Structure structure);
    void deleteStructure(Map credentials, Structure structure);

    // -- Application Configurations

    List<AppConfig> getAppConfigs(Map credentials);
    AppConfig updateAppConfig(Map credentials, AppConfig config);

    // -- User

    User authorize(String username, String password);
    User register(User user, String password);
    List<User> getAllUsers(Map credentials);
    List<User> getAllActiveUsers(Map credentials);
    User updateUserbyAdmin(Map credentials, User user);
    User changePassword(Map credentials, String newPassword);
    List<Group> getAllGroups(Map credentials);
    Group createGroup(Map credentials, Group group);
    Group updateGroup(Map credentials, Group group);
    boolean deleteGroup(Map credentials, Group group);
    List<User> getGroupUsers(Map credentials, Group group);
    List<Group> getUserGroups(Map credentials, User user);
    void addUsersToGroup(Map credentials, Group group, List<User> users);
    void removeUsersFromGroup(Map credentials, Group group, List<User> users);
    User getUserWithRelations(Map credentials, User user);
    User addUserRelation(Map credentials, User root, List<User> users, boolean assistant);
    User removeUserRelation(Map credentials, User root, List<User> users, boolean assistant);
    void changePasswordAdmin(Map credentials, User user, String password);
    long uploadUserImage(Map credentials, byte[] data);

    // -- Task

    List<FlowPermission> getFlowPermissions(Map credentials, int taskType);
    FlowPermission createFlowPermission(Map credentials, FlowPermission permission);
    void deleteFlowPermission(Map credentials, FlowPermission permission);
    void deleteFlowPermissions(Map credentials, List<FlowPermission> permissions);
    Integer[] getAllowedTaskStatuses(Map credentials, Task task);
    Task createTask(Map credentials, Task task, User forUser, boolean draft);
    TaskList findTasks(Map credentials, int page, int perPage, List<Condition> conditions);
    Task getTask(Map credentials, Task task);
    Task changeReceivers(Map credentials, Task task, List<TaskReceiver> receivers, boolean copy);
    Task changeTaskSubject(Map credentials, Task task, String newSubject);
    Task changeTaskPriority(Map credentials, Task task, Calendar dueDate, int priority);
    Task changeTaskStatus(Map credentials, Task task, String comment, int newStatus);
    TaskAttachment uploadAttachment(Map credentials, Task task, TaskAttachment data, byte[] content);
    byte[] downloadAttachment(Map credentials, Task task, TaskAttachment data);
    void removeAttachment(Map credentials, List<TaskAttachment> attachments);
    void deleteTask(Map credentials, Task task);
    Task addTaskParentRelation(Map credentials, Task task, List<TaskRelation> relations);
    Task removeTaskParentRelation(Map credentials, Task task, List<TaskRelation> relations);
    byte[] getTaskReport(Map credentials, Task task);

    // -- Binary

    byte[] download(Map credentials, long binaryId);

    // -- Analyze

    List getTaskCompetedReportData(Map credentials, Calendar c1, Calendar c2);

}
